package spolipar.bitcoin.bot.data;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class LiveDataStorage {
	
	private final static Map<StorageKey, Storage> m_storages = new ConcurrentHashMap<StorageKey, Storage>();
	private static LiveDataStorage s_instance = null;
	
	public static LiveDataStorage instance() {	return s_instance; }
	
	public static void init() {
		s_instance = new LiveDataStorage();
    }
		
	public void put(StorageKey sotrageKey, IMarketData data) {
		Storage storage = m_storages.get(sotrageKey);
		if(storage == null) {
			storage = new Storage(sotrageKey);
			m_storages.put(sotrageKey, storage);
		}
		storage.put(data);
	}

	public Storage getStorage(StorageKey key) {
		return m_storages.get(key);
	}
	
}
